<?php
/**
 * Created by PhpStorm.
 * User: lixiaohui
 * Date: 2015/9/28
 * Time: 13:03
 */

namespace Home\Controller;


use Think\Controller;

class InfoController extends Controller
{
    //发布内容列表
    public function infoList()
    {
        $columnId = I('columnId');
        //取栏目名
        $columnModel = M('column_info', 'js_')->where("id=%d and status=1", $columnId)->field('column')->find();
        if (count($columnModel) == 0) {//不存在的栏目ID
            $this->assign('columnModel', array("column" => "无此栏目"));
            $this->assign('publishModel', array());
            $this->display();
            return;
        }
        $publishModel = M('mes_publish', 'js_')->where("columnId=%d and status=1", $columnId)->field('id,title,publisherTime,intro')->select();
        /*dump($columnModel);
        dump($publishModel);*/

        $this->assign('publishModel', $publishModel);
        $this->assign('columnModel', $columnModel);
        $this->assign("bottomMenu", getBottomMenu());
        $this->display();
    }

    //发布内容详情
    public function detail()
    {
        $id = I('id');
        $needBack = I('needBack');
        $publishModel = M('mes_publish', 'js_')->where("id='%s'", $id)->field('title,content,homePage,publisherTime,columnId')->find();
        if ($publishModel == null) {
            $this->assign('columnModel', array("column", "无此栏目"));
            $this->assign('publishModel', array());
            $this->display();
            return;
        }
        $columnModel = M('column_info', 'js_')->where("id=%d", $publishModel['columnid'])->field('column')->find();

        /*dump($publishModel);
        dump($columnModel);*/

        $this->assign('publishModel', $publishModel);
        $this->assign('columnModel', $columnModel);
        $this->assign("bottomMenu", getBottomMenu());
        $this->assign("needBack", $needBack);
        $this->display();
    }

}